﻿using System;

using MySql.Data.MySqlClient;


namespace StagingAreaETL
{
    internal class TimeDIM
    {
        internal TimeDIM(DateTime time)
        {
            TimeKEY = String.Format("{0:yyyy-MM-dd-HH-mm-ss}", time);
            Date = String.Format("{0:dd.MM.yyyy}", time);
            DayTime = String.Format("{0:HH:mm:ss}", time);
        }

        internal readonly string TimeKEY;
        internal readonly string Date;
        internal readonly string DayTime;


        internal void SaveToDB()
        {
            MySqlConnection connection = DBHelper.getODSConnection();
            MySqlCommand command = connection.CreateCommand();

            command.CommandText = "insert IGNORE into Time values ('" + TimeKEY + "', '" + Date + "', '" +
                                  DBHelper.toString(DayTime) + "');";
            command.ExecuteNonQuery();

            connection.Close();
        }
    }
}
